#include <syntax_errors/matrix.h>

// it was not declared in the correct way.
Matrix::Matrix()
{
    //
}

Matrix::Matrix( Matrix const & other )
:
	// ','s are required at the end of each declaration
    rows_( other.rows_ ),
    cols_( other.cols_ ),
    storage_( other.storage_ )
{
    //
}

	// The ';' at the end of this line was not needed
Matrix::Matrix( unsigned int const & rows, unsigned int const & cols )
:
	// ','s are required at the end of each declaration
    rows_( rows ),
    cols_( cols ),
    storage_( rows * cols )
{
    //
}

double & Matrix::operator()( unsigned int const & row, unsigned int const & col )
{
    return *( storage_.begin() + ( col * row ) + col );
}

double const & Matrix::operator()( unsigned int const & row, unsigned int const & col ) const
{
	// a '*' was omitted after the return, since it's returning the reference we need the '*'
    return *( storage_.begin() + ( col * row ) + col );
}

// a ';' was wrongly inserted after the "other"
Matrix & Matrix::operator+=( Matrix const & other)
{
    std::vector<double>::iterator self_it = storage_.begin();
    std::vector<double>::const_iterator other_it = other.storage_.begin();

    if( rows_ == other.rows_ && cols_ == other.cols_ )
    {
		// we don't have to use '!==' because the symbol for comaring non-equal stuff is '!=' 
        for( ; self_it != storage_.end(); ++self_it, ++other_it )
        {
			// we need a '*' before "other_it" because we're dealing with references in this line
            *self_it += *other_it;
        }
    }

	//There is ';' is needed here instead of ':'
    return *this;
}

Matrix Matrix::operator+( Matrix const & other ) const
{
	// we are using references so a '*' is needed before "this"
    Matrix new_mat( *this );

    new_mat += other;

    return new_mat;
}
